package edu.whu.rose.clock.ssql.graphindex;

import java.util.HashMap;
import java.util.HashSet;

public class NewGraphIndexItem {

	private HashMap<Integer, HashSet<Integer>> data;
	private long size;
	
	public NewGraphIndexItem() {
		data = new HashMap<Integer, HashSet<Integer>>(8, 0.8f);
		size = 40;
	}
	
	public NewGraphIndexItem(HashMap<Integer, HashSet<Integer>> data, long size) {
		this.data = data;
		this.size = size;
	}
	
	public void add(int[] newGraphs, int vertex) {
		for (int i = 0; i < newGraphs.length; i++) {
			Integer g = new Integer(newGraphs[i]);
			if (data.containsKey(g)) {
				data.get(g).add(new Integer(vertex));
				size += 4;
			}
			else {
				HashSet<Integer> value = new HashSet<Integer>(8, 0.8f);
				value.add(new Integer(vertex));
				data.put(g, value);
				size += 32;
			}
		}
	}
	
	public HashMap<Integer, HashSet<Integer>> getData() {
		return data;
	}
	
	public long getSize() {
		return size;
	}
}
